<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: register.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."register.php";
include LOCALE.LOCALESET."user_fields.php";

$avloserid=$_GET['avloserid'];

if(isset($_GET['confirm']))
	{
	$id=$_GET['avloserid'];
	$confirm=$_GET['confirm'];
	if ($_GET['confirm'] == "ja" )
		{
		$query1="DELETE 
				 FROM avloser 
				 WHERE avloserid=$id";
		mysql_query($query1);
		header("Refresh: 1; url=visning.php?bekreftelse=ja");
		}else if ( $confirm == "nei" )
			{
			//header("Refresh: 1; url=profil.php?avloserid=".$id."");
			}
	}

//---------------------------------------------------------------------------------------------------------------------+
//----------Funksjon for oppdatering av persondata til DB   (Hoppes over hvis ikke oppdaterknappen er trykket)---------+
//---------------------------------------------------------------------------------------------------------------------+
//Henter sjekk fra URL
if(isset($_GET['oppdat_profil']))
	{
	$oppdat_profil=$_GET['oppdat_profil'];
	if($oppdat_profil=="ja")
		{
		if(isset($_GET['adv']))
			{
			echo "<h1 align='center'>Du m&aring; velge type!</h1>";
			}
					
			$avloserid=$_GET['avloserid'];
			$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
			mysql_select_db($GLOBALS['db_name'], $db); 
			
			$query="SELECT aktiv 
					FROM aktiv";
			$result=mysql_query($query);
			
			$options="";
			
			while ($row=mysql_fetch_array($result)) 
				{
				$aktivdb=$row['aktiv'];
				$options.="<OPTION VALUE=\"$aktivdb\">".$aktivdb;
				}
			
			$query="Select * 
					FROM arbeidstype
					WHERE avloserid=".$avloserid."
					AND type LIKE '%Admin%'";
			$result=mysql_query($query);
			$num=mysql_numrows($result);
			if($num==1){
				$admin=mysql_result($result,0,"type");
			}else if($num==0){
				$admin='uvalgt';
			}
			$query="Select * 
					FROM arbeidstype
					WHERE avloserid=".$avloserid."
					AND type LIKE '%Avl%'";
			$result=mysql_query($query);
			$num=mysql_numrows($result);
			if($num==1){
				$avl=mysql_result($result,0,"type");
			}else if($num==0){
				$avl='uvalgt';
			}
			$query="Select * 
					FROM arbeidstype
					WHERE avloserid=".$avloserid."
					AND type LIKE '%Annen%'";
			$result=mysql_query($query);
			$num=mysql_numrows($result);
			if($num==1){
				$annen=mysql_result($result,0,"type");
			}else if($num==0){
				$annen='uvalgt';
			}
			$query="Select * 
					FROM arbeidstype
					WHERE avloserid=".$avloserid."
					AND type LIKE '%Utenlandsk%'";
			$result=mysql_query($query);
			$num=mysql_numrows($result);
			if($num==1){
				$utenlandsk=mysql_result($result,0,"type");
			}else if($num==0){
				$utenlandsk='uvalgt';
			}
						
			$query="SELECT *
					FROM avloser, postkatalog
					WHERE avloserid=".$avloserid." 
					AND avloser.postnr = postkatalog.postnr"; 	

			$result=mysql_query($query);
			$num=mysql_numrows($result);					
			$i=0;
			while ($i < $num) 
				{
				$fornavn=mysql_result($result,$i,"fornavn");
				$etternavn=mysql_result($result,$i,"etternavn");
				$adresse=mysql_result($result,$i,"adresse");
				$postnr=mysql_result($result,$i,"postnr");
				$telefon=mysql_result($result,$i,"telefon");
				$mobil=mysql_result($result,$i,"mobil");
				$epost=mysql_result($result,$i,"epost");
				$aktiv=mysql_result($result,$i,"aktiv");
				$agronom=mysql_result($result,$i,"agronom");
				$poststed=mysql_result($result,$i,"poststed");
				$parorende=mysql_result($result,$i,"parorendenavn");
				$parorendetlf=mysql_result($result,$i,"parorendetlf");
				++$i; //teller økes med 1
				}
			//Skriver ut tabellen som persondata skal stå i 
			echo "
				<br></br> 
				<form action='profil.php?avloserid=$avloserid&oppdat_profil=lagre' method='post' >
				<input type='hidden' name='ud_avloserid' value=$avloserid>
				<table class='capmain' border='0' cellpadding='0' align='center' width='608px'>
					<tr>
						<th><font style='text-transform: capitalize;'>Informasjon om:&nbsp; $fornavn  $etternavn </font></th>
					</tr>
				</table>
				<table class='imagetable' border='0' cellpadding='5' tableborder='10' align='center'>
					<tr>	<th><b>Fornavn</b></th>		<td><input type='text' name='ud_fornavn' value='$fornavn'></td>		<th><b>Telefon</b></th>		<td><input type='text' name='ud_telefon' value='$telefon'></td>	</tr>
					<tr>	<th><b>Etternavn</b></th>	<td><input type='text' name='ud_etternavn' value='$etternavn'></td><th><b>Mobil</b></th>		<td><input type='text' name='ud_mobil' value='$mobil'></td>		</tr>
					<tr>	<th><b>Adresse</b></th>		<td><input type='text' name='ud_adresse' value='$adresse'></td>	<th><b>Epost</b></th>		<td><input type='text' name='ud_epost' value='$epost'></td>		</tr>
					<tr>	<th><b>Postnr</b></th>		<td ><input type='text' name='ud_postnr' value='$postnr'></td>		
					
					<th><b>Aktiv</b></th>		<td>";		if ($aktiv == 'JA')
															{
    											echo "<b>Ja: </b><input type='radio' name='ud_aktiv' value='JA' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Ja: </b><input type='radio' name='ud_aktiv' value='JA'/>";
															}
															if ($aktiv == 'NEI')  
															{
    											echo "<b>Nei: </b><input type='radio' name='ud_aktiv' value='NEI' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Nei: </b><input type='radio' name='ud_aktiv' value='NEI'/>";
															}
															
																										echo"	</td>	
					
					</tr>
					<tr>	<th><b>Poststed</b></th>	
							<td ><input type='text' name='ud_poststed' value='$poststed' readonly='readonly' style='background-color: #D4D4D4' ></td>
							
							<th><b>AgronomUtd</b></th>		<td>";		if ($agronom == 'JA')
															{
    											echo "<b>Ja: </b><input type='radio' name='ud_agronom' value='JA' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Ja: </b><input type='radio' name='ud_agronom' value='JA'/>";
															}
															if ($agronom == 'NEI')
															{
    											echo "<b>Nei: </b><input type='radio' name='ud_agronom' value='NEI' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Nei: </b><input type='radio' name='ud_agronom' value='NEI'/>";
															}
															
																										echo"	</td>	</tr>
					
					<tr>	<th ><b>Parorende</b></th><td ><input type='text' name='ud_paa' value='$parorende'></td>		
					
					
										
										<th><b>Administrasjon</b></th>		<td>";		if ($admin == 'Administrasjon')
															{
    											echo "<b>Ja: </b><input type='radio' name='ud_admin' value='Administrasjon' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Ja: </b><input type='radio' name='ud_admin' value='Administrasjon'/>";
															}
															if ($admin == 'uvalgt')  
															{
    											echo "<b>Nei: </b><input type='radio' name='ud_admin' value='uvalgt' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Nei: </b><input type='radio' name='ud_admin' value='uvalgt'/>";
															}
															
																										echo"	</td>	";
																										
										
						
							
														
								
														
													
    		
														
															
												
					echo"</td>
								</tr>				
		<tr>		<th><b>P&aring;r&oslash;rende tlf </b></th>	<td  ><input type='text' name='ud_paatlf' value='$parorendetlf'></td>			
					<th><b>Avl&oslash;ser</b></th>		<td>";		if ($avl == 'Avl&oslash;ser')
															{
    											echo "<b>Ja: </b><input type='radio' name='ud_avl' value='Avløser' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Ja: </b><input type='radio' name='ud_avl' value='Avløser'/>";
															}
															if ($avl == 'uvalgt')  
															{
    											echo "<b>Nei: </b><input type='radio' name='ud_avl' value='uvalgt' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Nei: </b><input type='radio' name='ud_avl' value='uvalgt'/>";
															}
															
																										echo"	</td> 
		
		</tr>
		<tr><th></th><td></td>
		
		<th><b>Annen N&aelig;ring</b></th>		<td>";		if ($annen == 'Annen n&aelig;ring')
															{
    											echo "<b>Ja: </b><input type='radio' name='ud_annen' value='Annen næring' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Ja: </b><input type='radio' name='ud_annen' value='Annen næring'/>";
															}
															if ($annen == 'uvalgt')  
															{
    											echo "<b>Nei: </b><input type='radio' name='ud_annen' value='uvalgt' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Nei: </b><input type='radio' name='ud_annen' value='uvalgt'/>";
															}
															
																										echo"	</td> 
																										
												</tr>
												<tr><th></th><td></td>
												
													<th><b>Utenlandsk arb.kraft</b></th>		<td>";		if ($utenlandsk == 'Utenlandsk arb.kraft')
															{
    											echo "<b>Ja: </b><input type='radio' name='ud_utenl' value='Utenlandsk arb.kraft' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Ja: </b><input type='radio' name='ud_utenl' value='Utenlandsk arb.kraft'/>";
															}
															if ($utenlandsk == 'uvalgt')  
															{
    											echo "<b>Nei: </b><input type='radio' name='ud_utenl' value='uvalgt' checked='checked' />";
															}
														else
															{    
   											 	echo "<b>Nei: </b><input type='radio' name='ud_utenl' value='uvalgt'/>";
															}
															
																										echo"	</td>
		
					
											
			     	
				
				</table>
				<table class='imagetable' border='0' cellpadding='5' tableborder='10' align='center'>
					<tr>
						<td align=center><input type='Submit' value='Oppdater info'></td>
						
					</tr>
				</table></form>";
						
						
		}else if($oppdat_profil=="lagre")
			{
			
				$avloserid=$_POST['ud_avloserid'];
				$ud_avloserid=$_POST['ud_avloserid'];
				$ud_fornavn=$_POST['ud_fornavn'];
				$ud_etternavn=$_POST['ud_etternavn'];
				$ud_adresse=$_POST['ud_adresse'];
				$ud_postnr=$_POST['ud_postnr'];
				$ud_telefon=$_POST['ud_telefon'];
				$ud_mobil=$_POST['ud_mobil'];
				$ud_epost=$_POST['ud_epost'];
				$ud_aktiv=$_POST['ud_aktiv'];
				$ud_agronom=$_POST['ud_agronom'];
				$ud_paa=$_POST['ud_paa'];
				$ud_paatlf=$_POST['ud_paatlf'];
				$ud_admin=$_POST['ud_admin'];
				$ud_avl=$_POST['ud_avl'];
				$ud_annen=$_POST['ud_annen'];
				$ud_utenl=$_POST['ud_utenl'];
				
				
				$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
				mysql_select_db($GLOBALS['db_name'], $db);  
			
				$query="UPDATE avloser 
						SET fornavn='$ud_fornavn',etternavn='$ud_etternavn', adresse='$ud_adresse', postnr='$ud_postnr', 
						telefon='$ud_telefon', mobil='$ud_mobil', epost='$ud_epost', aktiv='$ud_aktiv', agronom='$ud_agronom', 						                            parorendenavn='$ud_paa', parorendetlf='$ud_paatlf', kommentar=''
						WHERE avloserid='$ud_avloserid'";
						mysql_query($query);
						
				if($ud_admin=="Administrasjon"){
					$query="SELECT * 
							FROM arbeidstype
							WHERE avloserid=".$avloserid."
							AND type LIKE '%Administrasjon%'";
						$result=mysql_query($query);
						$num=mysql_numrows($result);
						if($num==0){
							$query="INSERT INTO arbeidstype VALUES('', 'Administrasjon', '$avloserid')"; 
							mysql_query($query);
						}
				}else if($ud_admin=="uvalgt"){
					$query="DELETE 
							FROM arbeidstype
							WHERE avloserid=".$avloserid."
							AND type LIKE '%Administrasjon%'";
						mysql_query($query);
				}
				
				if($ud_avl=="Avløser"){
					$query="SELECT * 
							FROM arbeidstype
							WHERE avloserid=".$avloserid."
							AND type LIKE '%Avl%'";
						$result=mysql_query($query);
						$num=mysql_numrows($result);
						if($num==0){
							$query="INSERT INTO arbeidstype VALUES('', 'Avl&oslash;ser', '$avloserid')"; 
							mysql_query($query);
						}
				}else if($ud_avl=="uvalgt"){
					$query="DELETE 
							FROM arbeidstype
							WHERE avloserid=".$avloserid."
							AND type LIKE '%Avl%'";
						mysql_query($query);
				}
				
				if($ud_annen=="Annen næring"){
					$query="SELECT * 
							FROM arbeidstype
							WHERE avloserid=".$avloserid."
							AND type LIKE '%Annen%'";
						$result=mysql_query($query);
						$num=mysql_numrows($result);
						if($num==0){
							$query="INSERT INTO arbeidstype VALUES('', 'Annen n&aelig;ring', '$avloserid')"; 
							mysql_query($query);
						}
				}else if($ud_annen=="uvalgt"){
					$query="DELETE 
							FROM arbeidstype
							WHERE avloserid=".$avloserid."
							AND type LIKE '%Annen%'";
						mysql_query($query);
				}
					
					if($ud_utenl=="Utenlandsk arb.kraft"){
					$query="SELECT * 
							FROM arbeidstype
							WHERE avloserid=".$avloserid."
							AND type LIKE '%Utenlandsk%'";
						$result=mysql_query($query);
						$num=mysql_numrows($result);
						if($num==0){
							$query="INSERT INTO arbeidstype VALUES('', 'Utenlandsk arb.kraft', '$avloserid')"; 
							mysql_query($query);
						}
				}else if($ud_utenl=="uvalgt"){
					$query="DELETE 
							FROM arbeidstype
							WHERE avloserid=".$avloserid."
							AND type LIKE '%Utenlandsk%'";
						mysql_query($query);
				}	
				
				
				echo "Vellykket.";
				header("Refresh: 1; url='profil.php?avloserid=$avloserid'");
				
														
					
			}else if($oppdat_profil=="slett")
				{
			//---------------------------------------------------------------------------------------------------------------------+
			//------Funksjon for bekreftelse og sletting av kontrakt mot DB   (Hoppes over hvis ikke slettknappen er trykket)------+
			//---------------------------------------------------------------------------------------------------------------------+
			
				echo "<br>
				<table class='capmain' border='0' background-color='#FF3300' cellpadding='0' align='center'>
					<tr>
						<th>Er du sikker p&aring;  at du vil slette denne avloseren?</th>
					</tr>
				</table>
				<h3 align=center>
					<h3 align=center><a href=profil.php?confirm=ja&avloserid=".$_GET['avloserid'].">Ja</a>
			
					&nbsp;&nbsp;|&nbsp;&nbsp;
					<a href=profil.php?confirm=nei&avloserid=".$_GET['avloserid'].">Nei</a></h3>
				</h3>";
				
				$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
				mysql_select_db($GLOBALS['db_name'], $db); 
				
				$query="SELECT forerkortid 
						FROM forerkort
						WHERE avloser=".$avloserid."";
				$forerkortid="forerkortid";

				$query="SELECT * 
						FROM arbeidstype 
						WHERE avloserid=".$avloserid."";
						$result=mysql_query($query);
				
				$query="SELECT * 
						FROM avloser, postkatalog
						WHERE avloserid=".$avloserid." 
						AND avloser.postnr = postkatalog.postnr"; 	
				
				$result=mysql_query($query);
				$num=mysql_numrows($result);					
				
				$i=0;										
				while ($i < $num) 
					{
					$fornavn=mysql_result($result,$i,"fornavn");
					$etternavn=mysql_result($result,$i,"etternavn");
					$adresse=mysql_result($result,$i,"adresse");
					$postnr=mysql_result($result,$i,"postnr");
					$telefon=mysql_result($result,$i,"telefon");
					$mobil=mysql_result($result,$i,"mobil");
					$epost=mysql_result($result,$i,"epost");
					$aktiv=mysql_result($result,$i,"aktiv");
					$agronom=mysql_result($result,$i,"agronom");
					$poststed=mysql_result($result,$i,"poststed");
					$type=mysql_result($result,$i,"type");
					++$i; //teller økes med 1
					}
					
				//Skriver ut tabellen som persondata skal stå i 
				echo "
					<br></br> 
					<table class='capmain' border='0' cellpadding='0' align='center'>
						<tr>
							<th><font style='text-transform: capitalize;'>Informasjon om:&nbsp; $fornavn  $etternavn </font></th>
						</tr>
					</table>
					
						<table class='imagetable' border='0' cellpadding='5' tableborder='10' align='center'>
						<tr>	<th><b>Etternavn</b></th>	<td>$etternavn</td>		</tr>
						<tr>	<th><b>Fornavn</b></th>		<td>$fornavn</td>		</tr>
						<tr>	<th><b>Mobil</b></th>		<td>$mobil</td>			</tr>
						<tr>	<th><b>Adresse</b></th>		<td>$adresse</td>		</tr>
						<tr>	<th><b>Postnr</b></th>		<td>$postnr</td>		</tr>
						<tr>	<th><b>Poststed</b></th>	<td>$poststed</td>		</tr>
						<tr>	<th><b>Telefon</b></th>		<td>$telefon</td>		</tr>
						<tr>	<th><b>Epost</b></th>		<td>$epost</td>			</tr>
						<tr>	<th><b>Aktiv</b></th>		<td>$aktiv</td>			</tr>
						<tr>	<th><b>Agronom</b></th>		<td>$agronom</td>		</tr>
						<tr>	<th><b>Type</b></th>		<td>$type, $type, $epost</td>			</tr>
						
					
					</table>
					<table class='imagetable' border='0' cellpadding='5' tableborder='10' align='center'>
						<tr>	
							<td align=center><form action='profil.php?avloserid=$avloserid&oppdat_profil=ja' method='post' >
							<input type='Submit' value='Endre info'></form>	</td>
							<td align=center><form action='slettansatt.php?confirm=ja&forerkortid=".$forerkortid."&avloserid=".$avloserid."&slett=ja&sjekk=nei' onSubmit='return validateUpdate()' method='post'>
							<input type='Submit' value='Slett person'>	</form>		</td>
						</tr>
					</table>";
			
				}
							
//---------------------------------------------------------------------------------------------------------------------+
//------------------------------------Slutt-på-funksjon-for-sletting-av-kontrakt---------------------------------------+
//---------------------------------------------------------------------------------------------------------------------+
				}else{	




//Oppkobling mot databasen. Opkoblingsinfo ligger i config.php

$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
mysql_select_db($GLOBALS['db_name'], $db); 


$query="SELECT forerkortid 
		FROM forerkort
		WHERE avloser=".$avloserid."";
$forerkortid="forerkortid";

$query="SELECT type 
		FROM arbeidstype
		WHERE avloserid=".$avloserid."
		AND type LIKE '%avl%'";
		 
$result=mysql_query($query);
$num=mysql_numrows($result);					

$i=0;										
while ($i < $num) 
	{
	$type2=mysql_result($result,$i,"type");
	++$i; //teller økes med 1
	}
		
$query="SELECT type 
		FROM arbeidstype
		WHERE avloserid=".$avloserid."
		AND type LIKE '%admin%'";
		 
$result=mysql_query($query);
$num=mysql_numrows($result);					

$i=0;										
while ($i < $num) 
	{
	$type1=mysql_result($result,$i,"type");
	++$i; //teller økes med 1
	}
	
$query="SELECT type 
		FROM arbeidstype
		WHERE avloserid=".$avloserid."
		AND type LIKE '%annen%'";
		 
$result=mysql_query($query);
$num=mysql_numrows($result);					

$i=0;										
while ($i < $num) 
	{
	$type3=mysql_result($result,$i,"type");
	++$i; //teller økes med 1
	}

$query="SELECT type 
		FROM arbeidstype
		WHERE avloserid=".$avloserid."
		AND type LIKE '%utenlandsk%'";
		 
$result=mysql_query($query);
$num=mysql_numrows($result);					

$i=0;										
while ($i < $num) 
	{
	$type4=mysql_result($result,$i,"type");
	++$i; //teller økes med 1
	}
			
		 
$query="SELECT * 
		FROM avloser, postkatalog 
		WHERE avloserid=".$avloserid." 
		AND avloser.postnr = postkatalog.postnr"; 	

$result=mysql_query($query);
$num=mysql_numrows($result);					

$i=0;										
while ($i < $num) 
	{
	$fornavn=mysql_result($result,$i,"fornavn");
	$etternavn=mysql_result($result,$i,"etternavn");
	$adresse=mysql_result($result,$i,"adresse");
	$postnr=mysql_result($result,$i,"postnr");
	$telefon=mysql_result($result,$i,"telefon");
	$mobil=mysql_result($result,$i,"mobil");
	$epost=mysql_result($result,$i,"epost");
	$aktiv=mysql_result($result,$i,"aktiv");
	$agronom=mysql_result($result,$i,"agronom");
	$poststed=mysql_result($result,$i,"poststed");
	$parorende=mysql_result($result,$i,"parorendenavn");
	$parorendetlf=mysql_result($result,$i,"parorendetlf");
	++$i; //teller økes med 1
	}
	
//Skriver ut tabellen som persondata skal stå i 


echo "


	<br></br> 
	<table class='capmain' border='0' cellpadding='0' align='center'>
		<tr>
			<td><font style='text-transform: capitalize;'>Informasjon om:&nbsp; $fornavn  $etternavn </font></td>
			
		</tr>
	</table>
	
		<table class='imagetable' border='0' cellpadding='5' tableborder='10' align='center'>
		<tr><th colspan='3'><a href='printer.php?avloserid=$avloserid' align='right'><img src='themes/Forest/images/print.png' height='50px' align='right'></a>
		<a href='printer.php?avloserid=$avloserid' align='left'><img src='themes/Forest/images/print.png'  height='50px' align='left'> <h1>Skriv ut!</h1></a></th>	</tr>
		<tr>	<th class='b'><b>Etternavn</b></th>		<th class='b' colspan='2'><b>Fornavn</b>	</tr>
		<tr>	<td class='a'>$etternavn</td>			<td class='a' colspan='2'>$fornavn</td>			</tr>
		<tr>	<th class='b'><b>Adresse</b></th>		<th class='b'><b>Postnr</b></th>	<th class='b'><b>Poststed</b></th>	</tr>
		<tr>	<td class='a'>$adresse</td>				<td class='a'>$postnr</td>			<td class='a'>$poststed</td>
					</tr>
		<tr>	<th class='b'><b>Telefon</b></th>    				<th class='b'><b>Mobil</b>	</th><th class='b' ><b>Epost</b></th>	</tr>
		<tr>	<td class='a'>$telefon</td>				<td class='a'>$mobil</td>	<td class='a'>$epost</td>				</tr>
		<tr>	<th class='b'><b>Aktiv</b></th>			<th class='b'><b>Type</b></th>	<th class='b'><b>Agronomutdannet</b></th>	</tr>				
		<tr>	<td class='a'>$aktiv</td>				<td class='a' >";if(isset($type1)){echo"$type1, ";} if(isset($type2)){echo"$type2, ";} if(isset($type3)){echo"$type3, ";} if(isset($type4)){echo"$type4, ";} echo"</td>		<td class='a'>$agronom</td>	</tr>
		<tr>	<th class='b'><b>P&aring;r&oslash;rendenavn</b></th>			<th colspan='2' class='b'><b>P&aring;r&oslash;rendetelefon </b></th>		</tr>
		<tr>	<td class='a'>$parorende</td>				<td colspan='2' class='a' >$parorendetlf</td>			</tr>
		
	
	
	</table>
		<table class='imagetable' border='0' cellpadding='5' tableborder='10' align='center'>
		<tr>	
			<th  align=center><form action='profil.php?avloserid=$avloserid&oppdat_profil=ja' method='post' ><input type='Submit' value='Endre info'>		</form>		</th>
			<th  align=center><form action='slettansatt.php?confirm=ja&forerkortid=".$forerkortid."&avloserid=".$avloserid."&slett=ja&sjekk=nei' onSubmit='return validateUpdate()' method='post'><input type='Submit' value='Slett person'>	</form>		</th>
		</tr>
	</table>";
//Her slutter koden for å hente ut persondata		
//--------------------------------------------------------------------------------------------
	}
	

	

//Her begynner funksjonen for kontrakt
//--------------------------------------------------------------------------------------------
$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
mysql_select_db($GLOBALS['db_name'], $db); 

$query="SELECT * 
		FROM arbeidskontrakt, avloser  
		WHERE avloser.avloserid=$avloserid
		AND avloser.avloserid=arbeidskontrakt.avloserid 
		ORDER BY oppsigelsesdato DESC" ;
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Arbeidskontrakt </font></td></tr></table>
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>Ansettelsesdato</b></th>
			<th><b>Oppsigelsesdato</b></th>
			
			
		</tr>";
$varsel='';
$varsel2='';
$varsel3='';

$i=0;
while ($i < $num) {
	$fra=mysql_result($result,$i,"ansettelsesdato");
	$til=mysql_result($result,$i,"oppsigelsesdato");
	$nyfra = date('d-M-Y', strtotime($fra));
	$nytil = date('d-M-Y', strtotime($til));
	
	
	
	$time = strtotime( $til );
	$dagsdato = date('Y-m-d');
	$dagstime = strtotime( $dagsdato );
	$differanse = $time - $dagstime;
	$utlop = round($differanse / 86400);
	if($utlop <= 31 && $utlop >=0)
	{$varsel='redkontrakt'; 
	$varsel2='akontrakt';
	$varsel3='bkontrakt';
	}else{$varsel='';
	$varsel2='';
	$varsel3='';}
	
	
++$i;


echo "
	<tr class='$varsel'>
		<td>$nyfra</td>
		<td>$nytil</td>
		
		
	</tr>
	";
} //Slutt på While-løkke
echo "


	<form action='lagrekontrakt.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	
	

	<tr>
		<th colspan='2' align='left'><input type='Submit' value='   Legg Til / Slett Kontrakt   '></th></form>
	</tr>
	</table>
	
	
	";




}else{
	
	echo"

	<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Arbeidskontrakt</font></td></tr></table>
	<form action='lagrekontrakt.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<th align='left'><input type='Submit' value='   Legg til ny kontrakt   '></th></form>
	</tr>
	</table>";
	

}//Slutt på IF-Setning
//Her slutter koden for å hente ut data om kontrakt
//--------------------------------------------------------------------------------------------

// Her begynner koden for å hente ut data om skolegang
$query="SELECT skolenavn, fag, aar 
		FROM skolegang, avloser 
		WHERE skolegang.avloserid=avloser.avloserid 
		AND skolegang.avloserid='$avloserid' 
		ORDER by skolegang.aar DESC";
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Skole</font></td></tr>
	</table>
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>&aring;r</b></th>
			<th><b>Fag</b></th>
			<th><b>Skole</b></th>
		</tr>";

$i=0;
while ($i < $num) {
	$aar=mysql_result($result,$i,"aar");
	$fag=mysql_result($result,$i,"fag");
	$skole=mysql_result($result,$i,"skolenavn");
++$i;


echo "
	<tr>
		<td>$aar</td>
		<td>$fag</td>
		<td>$skole</td>
	</tr>";
} //Slutt på While-løkke

echo "

	<form action='lagreskolegang.php?avloserid=".$avloserid."&sjekk=nei' method='post' >

	<tr>
		<th colspan='3' align='center'><input type='Submit' value='   Legg Til / Slett  Skole   '></th></form>
	</tr>
	</table>
	
	
	";
}else{
	
	echo "
	<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Skolegang</font></td></tr></table>
	<form action='lagreskolegang.php?avloserid=".$avloserid."&sjekk=nei' method='post' >
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<th align='left'><input type='Submit' value='   Legg til ny skole   '></th></form>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om skolegang
//--------------------------------------------------------------------------------------------
// Her begynner koden for å hente ut data om Fagbrev
$query="SELECT skole, fag, aar 
		FROM fagbrev, avloser 
		WHERE fagbrev.avloserid=avloser.avloserid 
		AND fagbrev.avloserid='$avloserid' 
		ORDER by fagbrev.aar DESC";
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Fagbrev</font></td></tr>
	</table>
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>&aring;r</b></th>
			<th><b>Fagbrev</b></th>
			<th><b>Skole</b></th>
		</tr>";

$i=0;
while ($i < $num) {
	$aar=mysql_result($result,$i,"aar");
	$fag=mysql_result($result,$i,"fag");
	$skole=mysql_result($result,$i,"skole");
++$i;


echo "
	<tr>
		<td>$aar</td>
		<td>$fag</td>
		<td>$skole</td>
	</tr>";
} //Slutt på While-løkke

echo "

	<form action='lagrefagbrev.php?avloserid=".$avloserid."&sjekk=nei' method='post' >

	<tr>
		<th colspan='3' align='center'><input type='Submit' value='   Legg Til / Slett  Skole   '></th></form>
	</tr>
	</table>
	
	
	";
}else{
	
	echo "
	<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Fagbrev</font></td></tr></table>
	<form action='lagrefagbrev.php?avloserid=".$avloserid."&sjekk=nei' method='post' >
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<th align='left'><input type='Submit' value='   Legg til nytt fagbrev   '></th></form>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om Fagbrev
//--------------------------------------------------------------------------------------------
//Her begynner koden for å hente ut data om kurs/sertifikat
$query="SELECT * 
		FROM kurs_sertifikat, avloser  
		WHERE avloser.avloserid=$avloserid
		AND avloser.avloserid=kurs_sertifikat.avloserid 
		ORDER BY aar DESC" ;
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Kurs/Sertifikat</font></td></tr></table>
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>&aring;r</b></th>
			<th><b>Kurs- Sertifikattype</b></th>
			<th><b>Sted</b></th>
		</tr>";

$i=0;
while ($i < $num) {
	$kaar=mysql_result($result,$i,"aar");
	$ktype=mysql_result($result,$i,"kurstype");
	$ksted=mysql_result($result,$i,"kurssted");
++$i;


echo "
	<tr>
		<td>$kaar</td>
		<td>$ktype</td>
		<td>$ksted</td>
	</tr>
	";
} //Slutt på While-løkke

echo "

	<form action='lagrekurs.php?avloserid=".$avloserid."&sjekk=nei' method='post'>

	<tr>
		<th colspan='3' align='center'><input type='Submit' value='   Legg Til / Slett Kurs   '></th></form>
	</tr>
	</table>
	
	
	";

}else{
	
	echo "
	<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>kurs/sertifikat</font></td></tr></table>
	<form action='lagrekurs.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
		
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<th align='left'><input type='Submit' value='   Legg til nytt kurs   '></th></form>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om kurs/sertifikat
//--------------------------------------------------------------------------------------------

//Her begynner funksjonen for arbeidserfaring
//--------------------------------------------------------------------------------------------

$query="SELECT * 
		FROM arbeidserfaring, avloser  
		WHERE avloser.avloserid=$avloserid
		AND avloser.avloserid=arbeidserfaring.avloserid 
		ORDER BY tildato DESC" ;
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Arbeidserfaring</font></td></tr></table>
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>Fra</b></th>
			<th><b>Til</b></th>
			<th><b>Sted</b></th>
			<th><b>Erfaring</b></th>
		</tr>";

$i=0;
while ($i < $num) {
	$fra=mysql_result($result,$i,"fradato");
	$til=mysql_result($result,$i,"tildato");
	$asted=mysql_result($result,$i,"arbeidssted");
	$erfaring=mysql_result($result,$i,"erfaring");
	$nyfra = date('d-M-Y', strtotime($fra));
	$nytil = date('d-M-Y', strtotime($til));
++$i;

echo "
	<tr>
		<td>$nyfra</td>
		<td>$nytil</td>
		<td>$asted</td>
		<td>$erfaring</td>
	</tr>
	";
} //Slutt på While-løkke

echo "

	<form action='lagreerfaring.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	
	<tr>
		<th colspan='4' align='center'><input type='Submit' value='   Legg Til / Slett Erfaring   '></th></form>
	</tr>
	</table>
	
	
	";

}else{
	echo "
	<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Arbeidserfaring</font></td></tr></table>
	<form action='lagreerfaring.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<th align='left'><input type='Submit' value='   Legg til ny erfaring   '></th></form>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om Arbeidserfaring

//Her begynner funksjonen for avlosermøte
//--------------------------------------------------------------------------------------------

$query="SELECT * 
		FROM avlosermote, avloser  
		WHERE avloser.avloserid=$avloserid
		AND avloser.avloserid=avlosermote.avloserid 
		ORDER BY dato DESC" ;
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Medarbeidersamtale</font></td></tr></table>
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			
			
			<th><b>Dato</b></th>
			<th><b>Info</b></th>
		</tr>";

$i=0;
while ($i < $num) {
	$dato=mysql_result($result,$i,"dato");
	$info=mysql_result($result,$i,"info");

	
	$nydato = date('d-M-Y', strtotime($dato));
	
	$time = strtotime( $dato );
	$dagsdato = date('Y-m-d');
	$dagstime = strtotime( $dagsdato );
	$differanse = $time - $dagstime;
	$utlop = round($differanse / 86400);
	if($utlop <= 31 && $utlop >=0)
	{$varsel='redmote'; 
	$varsel2='amote';
	$varsel3='bmote';
	}else{$varsel='';
	$varsel2='';
	$varsel3='';}
++$i;


echo "
	<tr class='$varsel'>
		
		<td class='$varsel3'>$nydato</td>
		<td class='$varsel3'>$info</td>
		
	</tr>
	";
} //Slutt på While-løkke

echo "

	<form action='avlosermote.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	


	<tr>
		<th colspan='2' align='center'><input type='Submit' value='   Legg Til / Slett M&oslash;te   '></th></form>
	</tr>
	</table>
	
	
	";

}else{
	echo "
	<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Medarbeidersamtale</font></td></tr></table>
	<form action='avlosermote.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<th align='left'><input type='Submit' value='   Legg til nytt m&oslash;te   '></th></form>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om avlosermote
//--------------------------------------------------------------------------------------------
//Her begynner koden for å hente ut data om førerkort
$query5="SELECT * 
		FROM forerkort
		WHERE forerkort.avloserid=".$avloserid."";
		
		$result5=mysql_query($query5);
		$num5=mysql_numrows($result5);
		
		if($num5>0){
		$fkid=mysql_result($result5,0,"forerkortid");

$query="SELECT oppkjoringklasse.klasse 
		FROM oppkjoringklasse, forerkort
		WHERE oppkjoringklasse.forerkortid=forerkort.forerkortid
		AND forerkort.avloserid=".$avloserid."";
		$result2=mysql_query($query);
		$num2=mysql_numrows($result2);
		
		
$query="SELECT * 
		FROM forerkortklasse, forerkort
		WHERE forerkortklasse.forerkortid=forerkort.forerkortid
		AND forerkort.avloserid=".$avloserid."";
		$result3=mysql_query($query);
		$num3=mysql_numrows($result3);
		
		

			$query="SELECT utgaar 
					FROM forerkort
					WHERE forerkort.avloserid=".$avloserid."";
					$result1=mysql_query($query);
					$num1=mysql_numrows($result1);
			
			
			
			$utgaar=mysql_result($result1,0,"utgaar");
			
			
			echo "<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
				<tr><td><font style='text-transform: capitalize;'>F&oslash;rerkort</font></td></tr></table>";
			
			echo "<table class='imagetable' border='0' cellpadding='5' align='center'>
			<tr>
			<th><b>F&oslash;rerkort klasse:</b></th><td>&nbsp;-&nbsp;";
			
			$i=0;
			while ($i < $num3) {
			$klasse=mysql_result($result3,$i,"klasse");
			echo "$klasse&nbsp;-&nbsp;";
			++$i;	
			}
			
			echo " </td>
			</tr>
			<tr>
			<th><b>Utg&aring;r dato:</b></th><td>&nbsp;-&nbsp;$utgaar&nbsp;-&nbsp;</td>
			</tr>
			<tr>
			<th><b>Oppkj&oslash;rt klasse:</b></th>
			<td>&nbsp;-&nbsp;";
			
			$i=0;
			while ($i < $num2) {
			$oppklasse=mysql_result($result2,$i,"klasse");
			echo "$oppklasse&nbsp;-&nbsp;";
			++$i;	
			}
			
			echo"</td>
			</tr>
			<tr>
			

			<form action='forerkort.php?avloserid=$avloserid&fkid=$fkid&ferdig=ja&utgaar=$utgaar' method='post'>
			
		
		
			<tr>
				<th colspan='2' align='center'><input type='Submit' value='   Endre F&oslash;rerkort   '></th></form>
			
			
			
			
			
			</tr>
			</table>";



		}else if ($num5==0) {
echo "
	<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>F&oslash;rerkort</font></td></tr></table>";
echo "<table class='imagetable' border='0' cellpadding='5' align='center'>";
echo "<form action='forerkort.php?avloserid=$avloserid' method='post'>
	<tr>
	<th>	<input type='Submit' value='Legg til'> </th></tr>
</table></form>";
}

// Her begynner koden for å hente ut data om egenvurdering
$query="SELECT  egenvurdering_id, egenvurdering.avloserid, sau_foring, sau_sanking, sau_lamming, storfe_foring, 
		storfe_melking, storfe_kalving, gris, fjerfe, traktor_enkel, traktor_allsidig, motorsag, melkerobot, 
		gjerding, fjervask, sau_foring_egen, sau_sanking_egen, sau_lamming_egen, storfe_foring_egen, storfe_melking_egen, 
		storfe_kalving_egen, gris_egen, fjerfe_egen, traktor_enkel_egen, traktor_allsidig_egen, motorsag_egen, melkerobot_egen, gjerding_egen, fjervask_egen
		FROM egenvurdering, avloser
		WHERE egenvurdering.avloserid = avloser.avloserid
		AND egenvurdering.avloserid =$avloserid";
$result=mysql_query($query);
$num=mysql_numrows($result);

if ($num>0){ 
echo "<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Egenvurdering</font></td></tr></table>
	
	<table class='imagetable' table border='0' cellpadding='5' align='center'>

";
$i=0;
while ($i < $num) {
	$sau_foring=mysql_result($result,$i,"sau_foring");
	$sau_sanking=mysql_result($result,$i,"sau_sanking");
	$sau_lamming=mysql_result($result,$i,"sau_lamming");
	$storfe_foring=mysql_result($result,$i,"storfe_foring");
	$storfe_melking=mysql_result($result,$i,"storfe_melking");
	$storfe_kalving=mysql_result($result,$i,"storfe_kalving");
	$gris=mysql_result($result,$i,"gris");
	$fjerfe=mysql_result($result,$i,"fjerfe");
	$traktor_enkel=mysql_result($result,$i,"traktor_enkel");
	$traktor_allsidig=mysql_result($result,$i,"traktor_allsidig");
	$motorsag=mysql_result($result,$i,"motorsag");
	$melkerobot=mysql_result($result,$i,"melkerobot");
	$gjerding=mysql_result($result,$i,"gjerding");
	$fjervask=mysql_result($result,$i,"fjervask");
	$sau_foring_egen=mysql_result($result,$i,"sau_foring_egen");
	$sau_sanking_egen=mysql_result($result,$i,"sau_sanking_egen");
	$sau_lamming_egen=mysql_result($result,$i,"sau_lamming_egen");
	$storfe_foring_egen=mysql_result($result,$i,"storfe_foring_egen");
	$storfe_melking_egen=mysql_result($result,$i,"storfe_melking_egen");
	$storfe_kalving_egen=mysql_result($result,$i,"storfe_kalving_egen");
	$gris_egen=mysql_result($result,$i,"gris_egen");
	$fjerfe_egen=mysql_result($result,$i,"fjerfe_egen");
	$traktor_enkel_egen=mysql_result($result,$i,"traktor_enkel_egen");
	$traktor_allsidig_egen=mysql_result($result,$i,"traktor_allsidig_egen");
	$motorsag_egen=mysql_result($result,$i,"motorsag_egen");
	$melkerobot_egen=mysql_result($result,$i,"melkerobot_egen");
	$gjerding_egen=mysql_result($result,$i,"gjerding_egen");
	$fjervask_egen=mysql_result($result,$i,"fjervask_egen");
	$sid=mysql_result($result,$i,"egenvurdering_id");
++$i;
echo "
	<form action='updateform_egenvurdering.php?avloserid=".$avloserid."' method='post'>
		<tr>
		<th></th>
		<th>Null</th>
		<th>Litt</th>
		<th>Ok</th>
		<th>Bra</th>
		<th></th>
		<th>Nei Takk</th>
		<th>Helst Ikke</th>
		<th>Ok</th>
		<th>Ja Takk</th>
		<th>&Oslash;nsker &aring; l&aelig;re mer</th>
	</tr>
	<tr>
		<th colspan='11'>Sau: </th>
	</tr>
	<tr>";
//----------------Her begynner SAU-FORING-------------------
echo"	
		<th>Foring </th><td>";
if ($sau_foring == 'Null') {
	echo "<input type='radio' name='sau_foring' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_foring' value='Null' disabled='disabled' />";
}
echo" </td><td>";
if ($sau_foring == 'Litt') {
    echo "<input type='radio' name='sau_foring' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_foring' value='Litt' disabled='disabled' />";
}
echo" </td><td>";
if ($sau_foring == 'Ok') {
echo"    <input type='radio' name='sau_foring' value='Ok' checked='checked' />";
}
else {    
echo" <input type='radio' name='sau_foring' value='Ok' disabled='disabled' />";
}
echo" </td><td>";
if ($sau_foring == 'Bra') {
    echo "<input type='radio' name='sau_foring' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_foring' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($sau_foring_egen == 'Nei Takk') {
    echo "<input type='radio' name='sau_foring_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_foring_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($sau_foring_egen == 'Ok') {
    echo "<input type='radio' name='sau_foring_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_foring_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($sau_foring_egen == 'Helst Ikke') {
    echo "<input type='radio' name='sau_foring_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_foring_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($sau_foring_egen == 'Ja Takk') {
    echo "<input type='radio' name='sau_foring_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_foring_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($sau_foring_egen == 'Lere Mer') {
    echo "<input type='radio' name='sau_foring_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_foring_egen' value='Lere Mer' disabled='disabled'/>";
} 

echo"</td></tr>
	       <tr>";
//---------------Her begynner SAU-SANKING------------------------------
echo"		   
<th>Sanking </th><td>";
if ($sau_sanking == 'Null') {
    echo "<input type='radio' name='sau_sanking' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_sanking' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($sau_sanking == 'Litt') {
    echo "<input type='radio' name='sau_sanking' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_sanking' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($sau_sanking == 'Ok') {
    echo "<input type='radio' name='sau_sanking' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_sanking' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($sau_sanking == 'Bra') {
    echo "<input type='radio' name='sau_sanking' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_sanking' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($sau_sanking_egen == 'Nei Takk') {
    echo "<input type='radio' name='sau_sanking_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_sanking_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($sau_sanking_egen == 'Ok') {
    echo "<input type='radio' name='sau_sanking_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_sanking_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($sau_sanking_egen == 'Helst Ikke') {
    echo "<input type='radio' name='sau_sanking_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_sanking_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($sau_sanking_egen == 'Ja Takk') {
    echo "<input type='radio' name='sau_sanking_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_sanking_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($sau_sanking_egen == 'Lere Mer') {
    echo "<input type='radio' name='sau_sanking_egen' value='Lere Mer' checked='checked' d/>";
}
else {    
    echo "<input type='radio' name='sau_sanking_egen' value='Lere Mer' disabled='disabled'/>";
} 

echo"</td></tr>
	<tr>";
//-------------------Her begynner SAU-LAMMING-----------------------------
echo"
		<th>Lamming </th><td>";
if ($sau_lamming == 'Null') {
    echo "<input type='radio' name='sau_lamming' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_lamming' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($sau_lamming == 'Litt') {
    echo "<input type='radio' name='sau_lamming' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_lamming' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($sau_lamming == 'Ok') {
    echo "<input type='radio' name='sau_lamming' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_lamming' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($sau_lamming == 'Bra') {
    echo "<input type='radio' name='sau_lamming' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_lamming' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($sau_lamming_egen == 'Nei Takk') {
    echo "<input type='radio' name='sau_lamming_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_lamming_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($sau_lamming_egen == 'Ok') {
    echo "<input type='radio' name='sau_lamming_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_lamming_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($sau_lamming_egen == 'Helst Ikke') {
    echo "<input type='radio' name='sau_lamming_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_lamming_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($sau_lamming_egen == 'Ja Takk') {
    echo "<input type='radio' name='sau_lamming_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_lamming_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($sau_lamming_egen == 'Lere Mer') {
    echo "<input type='radio' name='sau_lamming_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='sau_lamming_egen' value='Lere Mer' disabled='disabled'/>";
} 

echo"</td></tr>
	<tr>
		<th colspan='11'>Storfe:</th>
	</tr>
	<tr>";
//----------------------Her begynner STORFE-FORING------------------------
echo"
		<th>Foring </th><td>";
if ($storfe_foring == 'Null') {
    echo "<input type='radio' name='storfe_foring' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_foring' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_foring == 'Litt') {
    echo "<input type='radio' name='storfe_foring' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_foring' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_foring == 'Ok') {
    echo "<input type='radio' name='storfe_foring' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_foring' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_foring == 'Bra') {
    echo "<input type='radio' name='storfe_foring' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_foring' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($storfe_foring_egen == 'Nei Takk') {
    echo "<input type='radio' name='storfe_foring_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_foring_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($storfe_foring_egen == 'Ok') {
    echo "<input type='radio' name='storfe_foring_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_foring_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($storfe_foring_egen == 'Helst Ikke') {
    echo "<input type='radio' name='storfe_foring_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_foring_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_foring_egen == 'Ja Takk') {
    echo "<input type='radio' name='storfe_foring_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_foring_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($storfe_foring_egen == 'Lere Mer') {
    echo "<input type='radio' name='storfe_foring_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_foring_egen' value='Lere Mer' disabled='disabled'/>";
} 

echo"</td></tr>
	<tr>";
//------------------Her begynner STORFE-MELKING--------------------------------
echo"
		<th>Melking </th><td>";
if ($storfe_melking == 'Null') {
    echo "<input type='radio' name='storfe_melking' value='Null' checked='checked'/>";
}
else {    
    echo "<input type='radio' name='storfe_melking' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_melking == 'Litt') {
    echo "<input type='radio' name='storfe_melking' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_melking' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_melking == 'Ok') {
    echo "<input type='radio' name='storfe_melking' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_melking' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_melking == 'Bra') {
    echo "<input type='radio' name='storfe_melking' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_melking' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($storfe_melking_egen == 'Nei Takk') {
    echo "<input type='radio' name='storfe_melking_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_melking_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($storfe_melking_egen == 'Ok') {
    echo "<input type='radio' name='storfe_melking_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_melking_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($storfe_melking_egen == 'Helst Ikke') {
    echo "<input type='radio' name='storfe_melking_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_melking_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_melking_egen == 'Ja Takk') {
    echo "<input type='radio' name='storfe_melking_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_melking_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($storfe_melking_egen == 'Lere Mer') {
    echo "<input type='radio' name='storfe_melking_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_melking_egen' value='Lere Mer' disabled='disabled'/>";
} 

echo"</td></tr>";

//---------------------------Her begynner STORFE-MELKEROBOT-----------------------	
echo" 	<tr>
		<th>Melkerobot</th><td>";
if ($melkerobot == 'Null') {
    echo "<input type='radio' name='melkerobot' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='melkerobot' value='Null' disabled='disabled' />";
}
echo" </td><td>";
if ($melkerobot == 'Litt') {
    echo "<input type='radio' name='melkerobot' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='melkerobot' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($melkerobot == 'Ok') {
    echo "<input type='radio' name='melkerobot' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='melkerobot' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($melkerobot == 'Bra') {
    echo "<input type='radio' name='melkerobot' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='melkerobot' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($melkerobot_egen == 'Nei Takk') {
    echo "<input type='radio' name='melkerobot_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='melkerobot_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($melkerobot_egen == 'Ok') {
    echo "<input type='radio' name='melkerobot_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='melkerobot_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($melkerobot_egen == 'Helst Ikke') {
    echo "<input type='radio' name='melkerobot_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='melkerobot_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($melkerobot_egen == 'Ja Takk') {
    echo "<input type='radio' name='melkerobot_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='melkerobot_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($melkerobot_egen == 'Lere Mer') {
    echo "<input type='radio' name='melkerobot_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='melkerobot_egen' value='Lere Mer' disabled='disabled'/>";
} 

echo"</td></tr>
	 <tr>";
//---------------------------Her begynner STORFE-KALVING-----------------------	
echo"
		<th>Kalving </th><td>";
if ($storfe_kalving == 'Null') {
    echo "<input type='radio' name='storfe_kalving' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_kalving' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_kalving == 'Litt') {
    echo "<input type='radio' name='storfe_kalving' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_kalving' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_kalving == 'Ok') {
    echo "<input type='radio' name='storfe_kalving' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_kalving' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_kalving == 'Bra') {
    echo "<input type='radio' name='storfe_kalving' value='Bra' checked='checked'/>";
}
else {    
    echo "<input type='radio' name='storfe_kalving' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($storfe_kalving_egen == 'Nei Takk') {
    echo "<input type='radio' name='storfe_kalving_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_kalving_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($storfe_kalving_egen == 'Ok') {
    echo "<input type='radio' name='storfe_kalving_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_kalving_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($storfe_kalving_egen == 'Helst Ikke') {
    echo "<input type='radio' name='storfe_kalving_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_kalving_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($storfe_kalving_egen == 'Ja Takk') {
    echo "<input type='radio' name='storfe_kalving_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_kalving_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";

if ($storfe_kalving_egen == 'Lere Mer') {
    echo "<input type='radio' name='storfe_kalving_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='storfe_kalving_egen' value='Lere Mer' disabled='disabled'/>";
} 

echo"</td></tr>
	<tr>";
//------------------------Her begynner GRIS---------------------------------------
echo"
		<th>Gris: </th><td>";
if ($gris == 'Null') {
    echo "<input type='radio' name='gris' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gris' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($gris == 'Litt') {
    echo "<input type='radio' name='gris' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gris' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($gris == 'Ok') {
    echo "<input type='radio' name='gris' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gris' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($gris == 'Bra') {
    echo "<input type='radio' name='gris' value='Bra' checked='checked '/>";
}
else {    
    echo "<input type='radio' name='gris' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($gris_egen == 'Nei Takk') {
    echo "<input type='radio' name='gris_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gris_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($gris_egen == 'Ok') {
    echo "<input type='radio' name='gris_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gris_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($gris_egen == 'Helst Ikke') {
    echo "<input type='radio' name='gris_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gris_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($gris_egen == 'Ja Takk') {
    echo "<input type='radio' name='gris_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gris_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";

if ($gris_egen == 'Lere Mer') {
    echo "<input type='radio' name='gris_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gris_egen' value='Lere Mer' disabled='disabled'/>";
} 

echo"</td></tr>
	<tr>";
//-----------------------Her begynner FJERFE---------------------------
echo"
	<tr>
   <th>Fj&aelig;rfe:</th><td>";
if ($fjerfe == 'Null') {
    echo "<input type='radio' name='fjerfe' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjerfe' value='Null' disabled='disabled'/>";
}
echo" </td><td>";

if ($fjerfe == 'Litt') {
    echo "<input type='radio' name='fjerfe' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjerfe' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($fjerfe == 'Ok') {
    echo" <input type='radio' name='fjerfe' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjerfe' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($fjerfe == 'Bra') {
    echo "<input type='radio' name='fjerfe' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjerfe' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($fjerfe_egen == 'Nei Takk') {
    echo "<input type='radio' name='fjerfe_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjerfe_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($fjerfe_egen == 'Ok') {
    echo "<input type='radio' name='fjerfe_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjerfe_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($fjerfe_egen == 'Helst Ikke') {
    echo "<input type='radio' name='fjerfe_egen' value='Helst Ikke' checked='checked'/>";
}
else {    
    echo "<input type='radio' name='fjerfe_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($fjerfe_egen == 'Ja Takk') {
    echo "<input type='radio' name='fjerfe_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjerfe_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($fjerfe_egen == 'Lere Mer') {
    echo "<input type='radio' name='fjerfe_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjerfe_egen' value='Lere Mer' disabled='disabled'/>";
} 

echo"</td></tr>
	";
//------------------Her begynner TRAKTOR---------------------------
echo"<tr>
		<th colspan='11'>Traktor:</th>
	</tr>
	<tr>
		<th>Enkel</th><td>";
if ($traktor_enkel == 'Null') {
    echo "<input type='radio' name='traktor_enkel' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_enkel' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($traktor_enkel == 'Litt') {
    echo "<input type='radio' name='traktor_enkel' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_enkel' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($traktor_enkel == 'Ok') {
    echo "<input type='radio' name='traktor_enkel' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_enkel' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($traktor_enkel == 'Bra') {
    echo "<input type='radio' name='traktor_enkel' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_enkel' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($traktor_enkel_egen == 'Nei Takk') {
    echo "<input type='radio' name='traktor_enkel_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_enkel_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($traktor_enkel_egen == 'Ok') {
    echo "<input type='radio' name='traktor_enkel_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_enkel_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($traktor_enkel_egen == 'Helst Ikke') {
    echo "<input type='radio' name='traktor_enkel_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_enkel_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($traktor_enkel_egen == 'Ja Takk') {
    echo "<input type='radio' name='traktor_enkel_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_enkel_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($traktor_enkel_egen == 'Lere Mer') {
    echo "<input type='radio' name='traktor_enkel_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_enkel_egen' value='Lere Mer' disabled='disabled'";
} 

echo"</td></tr>
		  <tr>
		<th>Allsidig</th><td>";
if ($traktor_allsidig == 'Null') {
    echo "<input type='radio' name='traktor_allsidig' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_allsidig' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($traktor_allsidig == 'Litt') {
    echo "<input type='radio' name='traktor_allsidig' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_allsidig' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($traktor_allsidig == 'Ok') {
    echo "<input type='radio' name='traktor_allsidig' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_allsidig' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($traktor_allsidig == 'Bra') {
    echo "<input type='radio' name='traktor_allsidig' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_allsidig' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($traktor_allsidig_egen == 'Nei Takk') {
    echo "<input type='radio' name='traktor_allsidig_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_allsidig_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($traktor_allsidig_egen == 'Ok') {
    echo "<input type='radio' name='traktor_allsidig_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_allsidig_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($traktor_allsidig_egen == 'Helst Ikke') {
    echo "<input type='radio' name='traktor_allsidig_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_allsidig_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($traktor_allsidig_egen == 'Ja Takk') {
    echo "<input type='radio' name='traktor_allsidig_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_allsidig_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($traktor_allsidig_egen == 'Lere Mer') {
    echo "<input type='radio' name='traktor_allsidig_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='traktor_allsidig_egen' value='Lere Mer' disabled='disabled'";
} 

echo"</td></tr>
<tr>
		<th>motorsag:</th><td>";
if ($motorsag == 'Null') {
    echo "<input type='radio' name='motorsag' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='motorsag' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($motorsag == 'Litt') {
    echo "<input type='radio' name='motorsag' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='motorsag' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($motorsag == 'Ok') {
    echo "<input type='radio' name='motorsag' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='motorsag' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($motorsag == 'Bra') {
    echo "<input type='radio' name='motorsag' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='motorsag' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($motorsag_egen == 'Nei Takk') {
    echo "<input type='radio' name='motorsag_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='motorsag_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($motorsag_egen == 'Ok') {
    echo "<input type='radio' name='motorsag_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='motorsag_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($motorsag_egen == 'Helst Ikke') {
    echo "<input type='radio' name='motorsag_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='motorsag_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($motorsag_egen == 'Ja Takk') {
    echo "<input type='radio' name='motorsag_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='motorsag_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($motorsag_egen == 'Lere Mer') {
    echo "<input type='radio' name='motorsag_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='motorsag_egen' value='Lere Mer' disabled='disabled'";
} 

echo"</td></tr>";
//------------------HER-BEGYNNER-GJERDING--------------------------
echo"	<tr>
		<th>Gj&aelig;rding:</th><td>";
if ($gjerding == 'Null') {
    echo "<input type='radio' name='gjerding' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gjerding' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($gjerding == 'Litt') {
    echo "<input type='radio' name='gjerding' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gjerding' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($gjerding == 'Ok') {
    echo "<input type='radio' name='gjerding' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gjerding' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($gjerding == 'Bra') {
    echo "<input type='radio' name='gjerding' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gjerding' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($gjerding_egen == 'Nei Takk') {
    echo "<input type='radio' name='gjerding_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gjerding_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($gjerding_egen == 'Ok') {
    echo "<input type='radio' name='gjerding_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gjerding_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($gjerding_egen == 'Helst Ikke') {
    echo "<input type='radio' name='gjerding_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gjerding_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($gjerding_egen == 'Ja Takk') {
    echo "<input type='radio' name='gjerding_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gjerding_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($gjerding_egen == 'Lere Mer') {
    echo "<input type='radio' name='gjerding_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='gjerding_egen' value='Lere Mer' disabled='disabled'";
} 

echo"</td></tr>";
//------------------HER-BEGYNNER-FJERVASK--------------------------
echo"		  <tr>
		<th>Fj&oslash;rvask:</th><td>";
if ($fjervask == 'Null') {
    echo "<input type='radio' name='fjervask' value='Null' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjervask' value='Null' disabled='disabled'/>";
}
echo" </td><td>";
if ($fjervask == 'Litt') {
    echo "<input type='radio' name='fjervask' value='Litt' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjervask' value='Litt' disabled='disabled'/>";
}
echo" </td><td>";
if ($fjervask == 'Ok') {
    echo "<input type='radio' name='fjervask' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjervask' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";
if ($fjervask == 'Bra') {
    echo "<input type='radio' name='fjervask' value='Bra' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjervask' value='Bra' disabled='disabled'/>";
} 

echo"	</td>
		<th></th>				
		<td>";
if ($fjervask_egen == 'Nei Takk') {
    echo "<input type='radio' name='fjervask_egen' value='Nei Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjervask_egen' value='Nei Takk' disabled='disabled'/>";
}
echo" </td><td>";

if ($fjervask_egen == 'Ok') {
    echo "<input type='radio' name='fjervask_egen' value='Ok' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjervask_egen' value='Ok' disabled='disabled'/>";
}
echo" </td><td>";

if ($fjervask_egen == 'Helst Ikke') {
    echo "<input type='radio' name='fjervask_egen' value='Helst Ikke' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjervask_egen' value='Helst Ikke' disabled='disabled'/>";
}
echo" </td><td>";
if ($fjervask_egen == 'Ja Takk') {
    echo "<input type='radio' name='fjervask_egen' value='Ja Takk' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjervask_egen' value='Ja Takk' disabled='disabled'/>";
} 
echo" </td><td>";
if ($fjervask_egen == 'Lere Mer') {
    echo "<input type='radio' name='fjervask_egen' value='Lere Mer' checked='checked' />";
}
else {    
    echo "<input type='radio' name='fjervask_egen' value='Lere Mer' disabled='disabled'";
} 

echo"</td></tr>
";
} //Slutt på While-løkke


echo "

	<form action='updateform_egenvurdering.php?avloserid=".$avloserid."' method='post' >
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<th align='center'><input type='Submit' value='   Endre / Oppdater   '></th></form>
	</tr>
	</table>
	
	
	";
}else{
	
	echo "
	<br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Egenvurdering</font></td></tr></table>
	<form action='lagreegenvurdering.php?avloserid=".$avloserid."&sjekk=nei' method='post' >
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<th align='left'><input type='Submit' value='   Fyll ut egenvurdering   '></th></form>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om skolegang
//--------------------------------------------------------------------------------------------
//Her begynner funksjonen for opplasting av dokumenter
//--------------------------------------------------------------------------------------------

     $query = "select image_id, filename, filnavn from images WHERE images.avloserid=$avloserid";
    $result = mysql_query($query, $db);
 
    $images = array();
 
    while ($row = mysql_fetch_array($result)) {
        $image_id = $row['image_id'];
        $images[$image_id] = $row['filnavn'];
    }

echo "

    <br></br><table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td>Dokumenter</td></tr></table>
    
 
            <table class='imagetable' border='0' cellpadding='5' align='center'>";
                 if (count($images) == 0) { 
echo"         <tr><td><b>Ingen dokumenter</b></td></tr>";
                		 } else foreach ($images as $image_id => $filnavn) { 
echo"    	 <tr>
                       <td><b> <a href='dokumentview.php?image_id=$image_id' target='_BLANK'> $filnavn </a> </b>
                    </td></tr>";
                 } 
echo"         </table>
	
	

	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
	
	<form action='dokument.php?avloserid=".$avloserid."' method='post'>
	
	<th align='center'><input type='Submit' value='   Last Opp / Slett Dokument   '></th></form>
	</tr>
	</table><br></br>
    
"; //Slutt på IF-Setning
//Her slutter koden for å hente ut dokumenter
//----------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
//Her begynner funksjonen for Kommentar
//--------------------------------------------------------------------------------------------

$query=" SELECT * 
FROM kommentar 
WHERE kommentar.kommentarid=$avloserid";

$result=mysql_query($query);
$num=mysql_numrows($result);


$i=0;
while ($i < $num) {
$kommentar=mysql_result($result,$i,"kommentar");
$kommentarid=mysql_result($result,$i,"kommentarid");
++$i;

echo "
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Kommentar</font></td></tr></table>";

echo "<table class='imagetable' border='0' cellpadding='5' align='center'>
<form action='oppdaterkommentar.php?avloserid=$avloserid&sjekk=nei' method='post'>
<tr>
<td><textarea style='resize: none' rows='4' cols='76' name='kommentar' wrap='hard'>$kommentar</textarea></td>
</tr>
";


}
if ($num!=0) {

echo "
	<table class='imagetable' border='0' cellpadding='5' align='center'>
	
	<tr>
		<th>
			<input type='Submit' value='Oppdater'></form>
			
			</th><th><form action='slettkommentar.php?confirm=ja&kommentarid=".$kommentarid."&avloserid=".$avloserid."&slett=ja&sjekk=nei' onSubmit='return validateUpdate()' method='post'><input type='submit' value='Slett' /></form>
			
		</th>
	</tr>
	
	</table><br></br></table>";
}

else {
echo "
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><td><font style='text-transform: capitalize;'>Kommentar</font></td></tr></table>
	<form action='lagrekommentar.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>
	<input type='hidden' name='kommentarid' value=".$avloserid.">
	<input type='hidden' name='avloserid' value=".$avloserid.">
	<tr><td><textarea style='resize: none' rows='4' cols='75' name='kommentar' wrap='hard'>Notat!</textarea></td></tr>
	<tr>
		<th align='left'><input type='Submit' value='   Lagre   '></th></form>
	</tr>
	</table><br></br>
	
	
	";
}

 //Slutt på IF-Setning
//Her slutter koden for kommentar
//----------------------------------------------------------------------------------------

require_once THEMES."templates/footer.php";

?>
<!-- JavaScript and HTML codes by Quackit.com -->
<script language="javascript" type="text/javascript">
function validateUpdate(){
		var confirmLeave = confirm('Er du sikker?');
		return confirmLeave;
}
</script>